LAB - Viscous Drag

In this experiment, we measured the terminal speed of different diameter steel balls in corn syrup. The purpose of this notebook is to show you how to plot data and best-fit curve.


In [3]:
import matplotlib.pyplot as plt
from numpy import *

In [12]:
#tab-delimited data
#
#D  vterm  note that the first data point 0,0 was added to show the graph going through the origin
datalist = """
0	0
0.00238125	0.00674
0.003175	0.0113
0.00396875	0.0179
0.0047625	0.0242
0.00635	0.0391
""".split('\n')  # split this string on the "newline" character.

#
# Here we'll take the list of strings defined above and break it into actual numbers.
#

Dlist = [] #D
D2list = [] #D^2
vlist = [] #terminal speed

for s in datalist:
    if s:
        D,v = s.split()     # break string in two strings (using tab as the delimiter)
        D=float(D)          # convert string to float
        v=float(v)          # convert string to float
        Dlist.append(D)
        D2list.append(D*D)
        vlist.append(v)

slope=1100
vtheor=slope*array(D2list)

plt.title('terminal speed vs diameter')
plt.xlabel('D^2 (m)')
plt.ylabel('v_term (m/s)')
plt.plot(D2list,vlist,'b.', D2list, vtheor, 'r-')
plt.show()

In [8]:


In [ ]: